perm filename PAGE8.WEB[MF,ALS] blob
sn#759248 filedate 1984-06-26 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 @p function do_char:boolean
C00005 ENDMK
C⊗;
@p function do_char:boolean;
label 1,2,3,4,9997,9998,9999;
@d no_black==(min_y>max_y)
@<Remove white rows and columns@>=
@!debug
print_nl;
print_ln('before: minx=',min_x:1,' maxx=',max_x:1,' miny=',min_y:1,' maxy=',max_y:1);
gubed@/
y:=min_y;
while y≤max_y do begin
x:=min_x;
while x<=max_x do begin
if image=black then goto 1;
incr(x);
end;
incr(y);
min_y←y; {blank row at bottom now gone}
end;
1:
if no_black then begin
min_x←max_x+1;
goto 4; {why bother?}
end;
y:=max_y;
while y>min_y do begin
x:=min_x;
while x<=max_x do begin
if image=black then goto 2;
incr(x);
end;
decr(y);
max_y←y; {blank row at top now gone}
end;
2:
x:=min_x;
while x<max_x do begin
y:=min_y;
while y<=max_y do begin
if image=black then goto 3;
incr(y);
end;
incr(x);
min_x←x; {blank column at left now gone}
end;
3:
x:=max_x;
while x>min_x do begin
y:=min_y;
while y<=max_y do begin
if image=black then goto 4;
incr(y);
end;
decr(x);
max_x←x; {blank column at right now gone}
end;
4:
cols←max_x-min_x+1;
rows←max_y-min_y+1;
cols_offset[char_code]←-min_x;
rows_offset[char_code]←max_y;
num_bytes←4*((cols+31) div 32);
@!debug
print_ln('after : minx=',min_x:1,' maxx=',max_x:1,' miny=',min_y:1,' maxy=',max_y:1);
print_ln('cols=',cols:1,' rows=',rows:1);
gubed
@ While we were at it, we also snuck in a computation of how many
rows and columns are in the bounding box and the number of bytes
needed to report each row of pixels.
@<Glob...@>=
@!cols,@!rows: integer; {columns and rows of pixels}
@!num_bytes: integer; {needed bytes per row}